<script setup lang="ts">
import { useUserStore } from '@/store/modules/user';
import { ArrowDown } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router';
const router =useRouter()
const userStore=useUserStore()
const login=()=>{
  userStore.changeDialog(true)
}

const HandleCommand=(value:string)=>{
  if(value==='logout'){
    userStore.removeToken()
    router.push('/home')
  }else if(value==='name'){
    router.push('/user/certification')
  }else if(value==='order'){
    router.push('/user/order')
  }else{
    router.push('/user/patient')
  }

}
</script>

<template>
  <div class="top">
    <div class="content">
      <div class="left" @click="router.push('/home')">
        <img src="../../assets/images/logo.png" alt="">
        <p>尚医通 预约挂号统一平台</p>
      </div>
      <div class="right">
        <span class="help">帮助中心</span>
        <span @click="login" v-if="!userStore.userInfo.token">登录/注册</span>
        <el-dropdown v-else @command="HandleCommand">
          <span class="el-dropdown-link">
            {{ userStore.userInfo.name }}
            <el-icon class="el-icon--right"><arrow-down /></el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item command="name">实名认证</el-dropdown-item>
              <el-dropdown-item command="order">挂号订单</el-dropdown-item>
              <el-dropdown-item command="patient">就诊人管理</el-dropdown-item>
              <el-dropdown-item command="logout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.top {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  width: 100%;
  height: 70px;
  display: flex;
  justify-content: center;
  background-color: #fff;
  .content {
    width: 1200px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    .left {
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      img {
        width: 50px;
        height: 50px;
      }
      p {
        margin-left: 10px;
        font-size: 22px;
        color:#4490f1;
      }
    }
    .right {
      display: flex;
      align-items: center;
      justify-content: space-around;
      span {
        color: #666;
        font-size: 14px;
        
        }
        span:hover {
          color:#4490f1;
         cursor: pointer;
        }
      .help{
          margin-right:20px ;
      }
    }
  }
}
</style>